<?php
$this->widget('webroot.admin.protected.extensions.fancybox.EFancyBox', array('target' => '.fan', 'config' => array('width' => 700, 'height' => 500,'type'=>'iframe','hideOnOverlayClick'=>false,'onClosed'=>'js:function(){window.location.href="'.Yii::app()->createUrl("activity/detail",array('id'=>$row->activityid)).'";}')));
$this->widget('webroot.admin.protected.extensions.fancybox.EFancyBox', array('target' => '.detail', 'config' => array('width' => 690, 'height' => 500,'type'=>'iframe','hideOnOverlayClick'=>false)));
if($row->status==1){
	$timeArr[$row['serial']] = strtotime($row->starttime)-time();
}elseif($row->status==5){
	$timeArr[$row['serial']] = strtotime($row->endtime)+$row->delaytime-time();
}

?>
<script>
function showDaTu(src){
document.getElementById("defaultImg").src=src;
}
</script>
<?php $this->beginWidget('application.widget.site.bannerWidget'); ?>
<?php $this->endWidget(); ?>

<div id="contener1" _height="auto">
	<div class="contener1Top"></div>
	<table width="970" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td >
				<table width="930" border="0" align="center" cellpadding="0" cellspacing="0">
					<tr>
						<td width="500">商品名稱: <span class="green1"><?=$row->prize->prizename?></span></span></td>
						<td width="330">活動類別：<a href="#" title="<?=$row->class?>" target="_self"><?=$row->class?></a></span></td>
						<td width="200">
							<div class="fb-like" data-href="http://www.yahoo.com.tw" data-send="false" data-width="450" data-show-faces="false"></div>
						</td>
					</tr>
					<tr>
						<td>活動倒數：<span class="red"id="time_<?=$row->serial?>"></span> </td>
						<td>活動ID：<?=$row->serial?></td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="3" align="left" valign="top">活動資訊：<?=$row->new?></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<div class="contener1_box">
		<div class="contener1_left">
			<div class="contener1_IMG">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="26%" valign="top"><a href="<?=Yii::app()->createUrl("activity/track",array('id'=>$row->activityid))?>"><img src="images/Limit1.png" alt="限量" width="85" height="84" border="0" /></a></td>
						<td width="74%" align="left"><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pics[0]->path?>" name="defaultImg" width="320" height="240" id="defaultImg"></td>
					</tr>
				</table>
			</div>
			<div class="contener1_IMG2">
				<?php
			foreach($row->prize->pics as $pRow){
			?>
				<img src='<?=Yii::app()->params['prizePath']?>/<?=$pRow->path?>' onmouseover="showDaTu('<?=Yii::app()->params['prizePath']?>/<?=$pRow->path?>')">
				<?php
			}
			?>
			</div>
		</div>
		<div class="contener1_right">
			<div style="margin-top:65px; height:190px">
				<table width="280" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-bottom:13px">
					<tr>
						<td width="50%" height="20" align="center" bgcolor="#FFFFCC">抽獎號碼</td>
						<td width="50%" align="center" bgcolor="#FFFFCC">參與者</td>
					</tr>
					<?php
					if($row->records){
						for($i=0;$i<5;$i++){
						$record = $row->records[$i];
						if(!$record){
							continue;
						}
					?>
					<tr>
						<td height="20" align="center">
							<?=$record->code?>
						</td>
						<td align="center">
							<?=$record->user->username?>
						</td>
					</tr>
					<?php
						}
					}else{
					?>
					<tr>
						<td height="20" align="center" colspan="2">暫無記錄</td>
					</tr>
					<?php
					}
					?>
				</table>
				<a href="<?=Yii::app()->createUrl('activity/record',array('id'=>$row->activityid))?>" title="查看本次完整紀錄" class="detail">查看本次完整紀錄 </a></div>
			<div style="margin-top:10px; line-height:16px;">
				<p>可參加次數：<span class="red">
					<?=$row->times-$times?>
					</span></p>
				<?php
				if($row->hongyun){
				?>
				<p>需求鴻運點數：<span class="red">
					<?=$row->times-$hongyun?>
					</span> 點</p>
				<?php
				}
				?>
				<p>活動人數：<strong>
					<?=count($row->records)?>
					/
					<?=$row->people?>
					</strong></p>
				<?php
				if(!Yii::app()->user->isGuest){				
					if($row->status==2){
				?>
				<div class="button"> <a class="fan" href="<?=Yii::app()->createUrl('activity/join',array('id'=>$row->activityid))?>" title="試手氣" target="_new" >
					<div class="id3">試手氣</div>
					</a> </div>
				<?php
					}elseif($row->status>2){
				?>
				已結束
				<?php
					}else{
				?>
				未開始
				<?
					}
				}else{
				?>
				<a href="<?=Yii::app()->createUrl('site/login',array('return'=>base64_encode(Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid)))))?>" title="請先登錄"> 請先登錄 </a>
				<?php
				}
				?>
			</div>
		</div>
	</div>
	<div class="contener1_box"></div>
	<div class="contener1_box">
		<table width="970" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td height="20" background="images/ptBG1_01.gif" style="background-repeat:no-repeat; background-position:center bottom">&nbsp;</td>
			</tr>
			<tr>
				<td background="images/ptBG1_02.gif" style="background-repeat:repeat-y; background-position:center center">
					<table width="950" border="0" cellspacing="0" cellpadding="0" align="center">
						<tr>
							<td valign="middle"><img src="images/title09.gif" alt="競標注意事項" title="競標注意事項" width="950" height="23" /></td>
						</tr>
						<tr>
							<td valign="middle">
								<?=$row->notice?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="18" background="images/ptBG1_03.gif" style="background-repeat:no-repeat; background-position:center top">&nbsp;</td>
			</tr>
		</table>
	</div>
	<div class="contener1_box">
		<table width="970" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td height="20" background="images/ptBG1_01.gif" style="background-repeat:no-repeat; background-position:center bottom">&nbsp;</td>
			</tr>
			<tr>
				<td background="images/ptBG1_02.gif" style="background-repeat:repeat-y; background-position:center center">
					<table width="950" border="0" cellspacing="0" cellpadding="0" align="center">
						<tr>
							<td valign="middle"><img src="images/title10.gif" alt="產品詳細介紹" title="產品詳細介紹" width="950" height="23" /></td>
						</tr>
						<tr>
							<td valign="middle">
								<?=$row->prize->description?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="18" background="images/ptBG1_03.gif" style="background-repeat:no-repeat; background-position:center top">&nbsp;</td>
			</tr>
		</table>
	</div>
	<div class="contener1Bottom"></div>
</div>
<script>
$(document).ready(function() {
<?php
if($timeArr){
?>
RF = new Object();
<?php
	foreach($timeArr as $tKey=>$tValue){
?>
RF['<?=$tKey?>'] = '<?=$tValue?>';
<?php
	}
?>
for ($f in RF) {
	if ($f == null) { 
		continue;
	}
	onTimer($f,RF[$f],changeShowTime,onTimeEnd);
}
<?php
}
?>
});
 
// 该函数用于显示倒计时
function changeShowTime(id,time) {
    /* 该函数内编写显示倒计时的语句 */  
    $(id).html(time);    
}
//倒計時結束的時候執行的函數
function onTimeEnd(id){
	$.post('<?php echo CHtml::normalizeUrl(array('/activity/opration'));?>',{'serial':id}, function (data) {
		var ret = $.parseJSON(data);
		location.reload(true);
	});
}
</script> 
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/zh_TW/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>